<?php
/**
 * Created by PhpStorm.
 * User: yh
 * Date: 2017/12/8
 * Time: 14:09
 */
namespace app\admin\model;
use think\Model;
use app\admin\logic\State as States;
class Store_log extends Model
{
    use \app\common\traits\Common;
    /**
     *门店获取器
     * @param $value
     * @param $data
     * @return mixed
     */
    public function getMendianTextAttr($value, $data){
        // 静态获取器
        $status = collect(self::getCommonModel()->getStore())->column('name','id');
        // 动态获取器
        // $status = Db::table('jtds_users')->cache(3600)->column('username', 'id');
        return $status[$data['mendian']];
    }

    /**
     *门市获取器
     * @param $value
     * @param $data
     * @return mixed
     */
    public function getMenshiTextAttr($value, $data){
        $status = collect(self::getCommonModel()->getUserByDeparId(2))->column('username','id');
        return $status[$data['menshi']];
    }

    /**
     * 订单状态获取器
     * @param $value
     * @param $data
     * @return mixed
     */
    public function getStateTextAttr($value, $data){
        $state = new States();
        $status = $state->statesToText();
        return $status[$data['state']];
    }


    /**
     * 到店流失原因获取器
     * @param $value
     * @param $data
     * @return mixed
     * @author: Guo
     */
    public function getInstoreyyTextAttr($value, $data)
    {
        // 静态获取器
        $status = collect(self::getCommonModel()->getInstore())->column('title', 'id');
        return $status[$data['instoreyy']];
    }

    /**
     * 未到流失原因获取器
     * @param $value
     * @param $data
     * @return mixed
     * @author: Guo
     */
    public function getNostoreTextAttr($value, $data)
    {
        // 静态获取器
        $status = collect(self::getCommonModel()->noStore())->column('title', 'id');
        // 动态获取器
        // $status = Db::table('jtds_users')->cache(3600)->column('username', 'id');
        return $status[$data['nostore']];
    }

    /**
     * 支付方式获取器
     * @param $value
     * @param $data
     * @return mixed
     */
    public function getPaymentTextAttr($value, $data)
    {
        $status = collect(self::getCommonModel()->getPayment())->column('title', 'id');
        return $status[$data['payment']];
    }

    /**
     * 摄影师获取器
     * @param $value
     * @param $data
     * @return mixed
     */
    public function getPhotoGrapherTextAttr($value, $data)
    {
        $status = collect(self::getCommonModel()->getUserByDeparId(6))->column('username', 'id');
        return $status[$data['photo_grapher']];
    }

    /**
     * 操作人员获取器
     * @param $value
     * @param $data
     * @return mixed
     * @author: wu
     */
    public function getOperatorTextAttr($value, $data){
        $status = collect(self::getCommonModel()->getAllUserInfo())->column('username','id');
        return $status[$data['operator']];
    }



}